package net.suncapper.wcss.web.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.suncapper.wcss.model.dto.PageDTO;
import net.suncapper.wcss.model.dto.ProductDTO;
import net.suncapper.wcss.model.vo.ProductVO;
import org.springframework.web.bind.annotation.RequestMapping;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import net.suncapper.wcss.common.JsonResponse;
import net.suncapper.wcss.service.IProductService;
import net.suncapper.wcss.model.domain.Product;


/**
 *
 *  前端控制器
 *
 *
 * @author ztr
 * @since 2025-11-10
 * @version v1.0
 */
@RestController
@RequestMapping("/api/product")
public class ProductController {

    private final Logger logger = LoggerFactory.getLogger( ProductController.class );

    @Autowired
    private IProductService productService;
    @PostMapping("save")
    public JsonResponse save(@RequestBody ProductDTO productDTO){
        return productService.productSave(productDTO);
    }
    @GetMapping("list")
    public JsonResponse list(ProductDTO productDTO, PageDTO pageDTO){
       Page<ProductVO> page =productService.pagelist(productDTO,pageDTO);
       return JsonResponse.success(page);
    }
}

